package com.yanqu.road.server.cmd.activity.dunhuangshiku;

import com.yanqu.road.pb.dunhuangshiku.DunHuangShiKuProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.dunhuangshiku.DunHuangShiKuModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @Description
 * @Author cwq
 * @Data 2021/11/27 15:42
 */
@Cmd(code = GameProtocol.S_DUN_HUANG_SHI_KU_GET_USER_DATA_FROM_CROSS, desc = "敦煌石窟获取用户数据 跨服返回区服 协议")
public class DunHuangShikuGetUserDataFromCrossCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        DunHuangShiKuProto.DunHuangShiKuGetUserDataRespMsg builder = DunHuangShiKuProto.DunHuangShiKuGetUserDataRespMsg.parseFrom(packet.getBytes());
        // 同步玩家数据
        if(builder.getRet() == 0){
            DunHuangShiKuModule dunHuangShiKuModule = player.getModule(DunHuangShiKuModule.class);

            dunHuangShiKuModule.regionId = builder.getUserInfo().getRegionId();
            dunHuangShiKuModule.teamId = (int)(builder.getUserInfo().getTeamId());
        }
        player.sendPacket(ClientProtocol.U_DUN_HUANG_SHI_KU_GET_USER_DATA, builder.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
